const path = require('path');
const fs = require('fs');

// // url: 类似 '/static/'
// // dir: 类似 __dirname + '/static'
function staticFiles(url, dir) {

    return async (ctx, next) => {
        let rpath = ctx.request.path;
        console.log(rpath, "path");
        console.log(url);
        if (rpath.startsWith(url)) {
            //获取完整的路径
            let fp = path.join(dir, rpath.substring(url.length));
            fs.exists(fp,function(a){
                if(a){
                    
                }
            })

        }
        await next();
    }
}

module.exports = staticFiles;